<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <script th:src="@{/jquery-3.6.0.min.js}" ></script>
</head>

<body>
<h3 style="color: gold">欢迎登录</h3>
<form  onsubmit="return false" method="get">
    用户名:<input type="text" name="userName" id="userName"><br/>
    密码:<input type="password" name="password" id="password"><br/>
    <input type="button" value="提交" id="doLogin">
</form>
</body>

<script>
    $(function(){

        $("#doLogin").click(function(){
            var userName = $("#userName").val()
            var password = $("#password").val()

            $.ajax({
                type:'get',
                url:'/doLogin?userName='+userName+'&password='+password,
                success:function(ret){
                    if(ret){
                        window.location.href='/user/list'
                    }else{
                        alert('登录账号密码错误!')
                    }
                }
            })

        })

    })
</script>

</html>